package cn.yuanqiao.archive.webservice.cconfig;

import org.apache.cxf.Bus;
import org.apache.cxf.bus.spring.SpringBus;
import org.apache.cxf.jaxws.JaxWsServerFactoryBean;
import org.apache.cxf.transport.servlet.CXFServlet;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.annotation.PostConstruct;
import java.util.HashMap;
import java.util.Map;

@Configuration
public class CxfConfig {

    @Autowired
    private Bus bus;

    @PostConstruct
    public void init() {
        Map<String, Object> properties = new HashMap<>();
        properties.put("org.apache.cxf.stax.maxTextLength", 1048576000);
        bus.setProperties(properties);
    }

    @Bean
    public CXFServlet cxfServlet() {
        return new CXFServlet();
    }

    @Bean
    public Bus springBus() {
        return new SpringBus();
    }
}
